﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace Portal.Cms.Render
{
    public class TouchScreenUtility
    {
        public static DateTime FirstDateOfWeek(int year, int weekNum, CalendarWeekRule rule)
        {
            DateTime jan1 = new DateTime(year, 1, 1);

            int daysOffset = DayOfWeek.Monday - jan1.DayOfWeek;
            DateTime firstMonday = jan1.AddDays(daysOffset);
            var cal = CultureInfo.CurrentCulture.Calendar;
            int firstWeek = cal.GetWeekOfYear(firstMonday, rule, DayOfWeek.Monday);

            if (firstWeek <= 1)
            {
                weekNum -= 1;
            }

            DateTime result = firstMonday.AddDays((weekNum - 1) * 7);
            return result;
        }


        public static string GetDayOfWeek()
        {
            if (System.DateTime.Now.DayOfWeek == DayOfWeek.Monday)
            {
                return "Thứ hai";
            }
            if (System.DateTime.Now.DayOfWeek == DayOfWeek.Tuesday)
            {
                return "Thứ ba";
            }
            if (System.DateTime.Now.DayOfWeek == DayOfWeek.Wednesday)
            {
                return "Thứ tư";
            }
            if (System.DateTime.Now.DayOfWeek == DayOfWeek.Thursday)
            {
                return "Thứ năm";
            }
            if (System.DateTime.Now.DayOfWeek == DayOfWeek.Friday)
            {
                return "Thứ sáu";
            }
            if (System.DateTime.Now.DayOfWeek == DayOfWeek.Saturday)
            {
                return "Thứ bảy";
            }
            return "Chủ nhật";
        }
    }
}
